unit SeriNoAyir;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, siComp;

type
  TfmSeriNoAyir = class(TForm)
    Panel1: TPanel;
    Panel2: TPanel;
    M1: TMemo;
    Button1: TButton;
    Label1: TLabel;
    Panel3: TPanel;
    Label5: TLabel;
    M2: TMemo;
    Panel4: TPanel;
    M3: TMemo;
    Label3: TLabel;
    M4: TMemo;
    Label4: TLabel;
    Panel5: TPanel;
    Label2: TLabel;
    M5: TMemo;
    cbSistem: TCheckBox;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  fmSeriNoAyir: TfmSeriNoAyir;

implementation
uses data, ana1;
{$R *.dfm}

procedure TfmSeriNoAyir.Button1Click(Sender: TObject);
var a1, a2: integer;
  durum: boolean;
  st: string;
  chk: array[1..8192, 1..2] of string;
label CIK;
begin
  M2.Clear;
  M3.Clear;
  m4.Clear;
  m5.Clear;

  for a1 := 0 to -1 + M1.lines.Count do
  begin
    if cbSistem.Checked then
    begin
      OpenQueryOnDataSet('Select Serinos from Fatharhar Where Serinos="' + m1.lines[a1] + '"', dm.Bosislem);
      if dm.Bosislem.RecordCount = 1 then
        M5.lines.Add(dm.Bosislem.FieldByName('Serinos').AsString);
    end;

    chk[A1 + 1, 1] := 'O';
    chk[A1 + 1, 2] := m1.lines[a1];
    for a2 := 0 to -1 + M1.lines.Count do begin
      if (M1.lines[a1] = M1.lines[a2]) and (A1 <> A2) then
      begin
        st := m1.lines[a2];
        chk[A1 + 1, 1] := 'X';
        chk[A1 + 1, 2] := ST;
      end;
    end;
    if chk[A1 + 1, 1] = 'O' then begin
      M3.lines.Add(M1.lines[a1]);
    end else begin
      M2.lines.Add(M1.lines[a1]);
    end;
  end;

  for a1 := 0 to -1 + M1.Lines.Count do begin
    for a2 := 0 to -1 + m4.Lines.Count do begin
      if m4.lines[a2] = chk[A1 + 1, 2] then goto CIK;
    end;

    M4.Lines.add(chk[A1 + 1, 2]);
    CIK:
  end;
end;

procedure TfmSeriNoAyir.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  Action := caFree;
  fmSeriNoAyir := nil;
end;

procedure TfmSeriNoAyir.Button2Click(Sender: TObject);
begin
  M1.Clear;
  M2.Clear;
  M3.Clear;
  M4.Clear;
  M5.Clear;
end;

end.
